﻿<AddDataFormTemplateSpec
  xmlns="bb_appfx_adddataformtemplate"
  xmlns:c="bb_appfx_commontypes"
  ID="096df9ec-1597-4bd6-b849-598390efd61e"
  Name="ConstituentMinimal Add Data Form Custom"
  Description="Add Constituent with just KeyName and Lookup ID"
  Author="Blackbaud Professional Services"
  DataFormInstanceID="9073d730-d935-4d0c-9394-558ecae4c8b2"
  RecordType="Constituent"
  c:SecurityUIFolder="Service Bus Adapter"
  >

    <SPDataForm>
        <SaveImplementation SPName="USP_DATAFORMTEMPLATE_ADD_CONSTITUENTMINIMAL">
            <c:CreateProcedureSQL>
                <![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_ADD_CONSTITUENTMINIMAL
(
  @ID uniqueidentifier = null output
 ,@CUSTOMIDENTIFIER nvarchar(100) = ''
 ,@KEYNAME nvarchar(100) = ''
)
as
set nocount on;

DECLARE @CHANGEAGENTID uniqueidentifier = null;
set @id = isnull(@id,newid());

if @CHANGEAGENTID is null begin
  exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
end;

declare @CURRENTDATE datetime = getdate();

begin try
  insert into dbo.CONSTITUENT
  (
    ID
   ,CUSTOMIDENTIFIER
   ,KEYNAME
   ,ADDEDBYID
   ,CHANGEDBYID
   ,DATEADDED
   ,DATECHANGED
  )
  values
  (
    @ID
   ,@CUSTOMIDENTIFIER
   ,@KEYNAME
   ,@CHANGEAGENTID
   ,@CHANGEAGENTID
   ,@CURRENTDATE
   ,@CURRENTDATE
  );
end try
begin catch
  exec dbo.USP_RAISE_ERROR;
  return 1;
end catch

return 0;
]]>
            </c:CreateProcedureSQL>
        </SaveImplementation>
    </SPDataForm>

    <c:FormMetaData FixedDialog="true">
        <c:FormFields>
            <c:FormField FieldID="CUSTOMIDENTIFIER" Caption="Custom Identifier (Lookup ID)" DataType="String" MaxLength="100" />
            <c:FormField FieldID="KEYNAME" Caption="Key Name" DataType="String" MaxLength="100" />
        </c:FormFields>
    </c:FormMetaData>
</AddDataFormTemplateSpec>